(function(){

    fetch("http://chst.vip:1234/api/getcoupon")
    .then(body=>body.json())
    .then(res=>{
        console.log(res);
        // let result= res.result[0]
        // ${result.}
        let html=""
        res.result.forEach(item => {

            html+=`
            <div couponid=${item.couponId}>
                    <img src="" alt="">
                    <p>${item.couponTitle}</p>
                </div>
            `
            
        });
        
        $('main .info').html(html)


        let dv= [...$('main .info div')]
        console.log(dv);

        dv.forEach(div=>{
            console.log(div);
            div.onclick=function(){
                let couponid=this.getAttribute('couponid')
                // console.log(couponid);

                location.href =`../pages/couponproduct.html?couponid=${couponid}`
            }
        })
    })


   




})()